import pandas as pd
import subprocess
import sys
import os
import time


def convert_seconds(seconds):
    hours = seconds // 3600
    remaining_seconds = seconds % 3600
    minutes = remaining_seconds // 60
    final_seconds = remaining_seconds % 60
    return hours, minutes, final_seconds


def write_csv(file_path, header_list, data_lists): 
    
    assert not len(data_lists) == 0
    assert len(header_list) == len(data_lists[0])

    for i in range(len(data_lists)): 

        frame = pd.DataFrame([data_lists[i]], columns = header_list)
        if i == 0: 
            frame.to_csv(file_path, mode = 'w', header = True, index = False)
        else: 
            frame.to_csv(file_path, mode = 'a', header = not os.path.exists(file_path), index = False)
